﻿@model Bonobo.Git.Server.Models.RepositoryDetailModel
@{
    Layout = "~/Views/Repository/_RepositoryLayout.cshtml";
    ViewBag.Title = Resources.Repository_Detail_Title;
}
@if (Model != null)
{
    <div class="pure-form pure-form-aligned detail">
        <fieldset>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Name)
                @Model.Name
                @switch (Model.Status)
                {
                    case RepositoryDetailStatus.Valid:
                        break;
                    case RepositoryDetailStatus.Missing:
                        <span class="status">(Missing)</span>
                        break;
                    case RepositoryDetailStatus.Unknown:
                    default:
                    <span class="status">(Status Unknown)</span>
                        break;
                }
            </div>
            <div class="pure-control-group">
                <label>@Resources.Repository_Detail_Location</label>
                <button class="pure-button copy-to-clip-button" data-clipboard-target=".git-url-text"><i class="fa fa-copy"></i>@Resources.Copy</button>
                <span class="git-url-text">@Model.GitUrl</span>
            </div>

            @if (User.Identity.IsAuthenticated) {
                <div class="pure-control-group">
                    <label>
                        @Resources.Repository_Detail_Location_Personal
                    </label>
                    <button class="pure-button copy-to-clip-button" data-clipboard-target=".personal-url-text"><i class="fa fa-copy"></i>@Resources.Copy</button>
                    <span class="personal-url-text">@Model.PersonalGitUrl</span>
                </div>
            }

            <div class="pure-control-group">
                @Html.LabelFor(m => m.Group)
                @Model.Group
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Description)
                @Model.Description
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.AllowAnonymous)
                @if (Model.AllowAnonymous)
                {
                    @Resources.Repository_Detail_Yes
                }
                else
                {
                    @Resources.Repository_Detail_No
                }
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.AllowAnonymousPush)
                @Html.DisplayEnum(Model.AllowAnonymousPush)
            </div>

            <div class="pure-control-group">
                @Html.LabelFor(m => m.LinksUseGlobal)
                @Html.CheckBoxFor(m => m.LinksUseGlobal, new { disabled=""})
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.LinksRegex)
                @Html.TextBoxFor(m => m.LinksRegex, new { @readonly=""})
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.LinksUrl)
                @Html.TextBoxFor(m => m.LinksUrl, new { @readonly=""})
            </div>
            @if (AppSettings.IsPushAuditEnabled) {
                <div class="pure-control-group">
                    @Html.LabelFor(m => m.AuditPushUser)
                    @if (Model.AuditPushUser)
                    {
                        @Resources.Repository_Detail_Yes
                    }
                    else
                    {
                        @Resources.Repository_Detail_No
                    }
                </div>
            }
                <div class="pure-control-group">
                @Html.LabelFor(m => m.Users)
                @for (int i = 0; i < Model.Users.Length; i++)
                {
                        @Html.ActionLink(@Model.Users[i].DisplayName, "Detail", "Account", new { id = @Model.Users[i].Id}, new { title = @Model.Users[i].Username })
                        if (i + 1 != Model.Users.Length)
                        {
                            <text>, </text>
                        }
                    }
                </div>
                <div class="pure-control-group">
                @Html.LabelFor(m => m.Administrators)
                @for (int i = 0; i < Model.Administrators.Length; i++)
                    {
                        @Html.ActionLink(@Model.Administrators[i].DisplayName, "Detail", "Account", new { id = @Model.Administrators[i].Id }, new { title = @Model.Administrators[i].Username })
                        if (i + 1 != Model.Administrators.Length)
                        {
                            <text>, </text>
                        }
                    }
                </div>
                    <div class="pure-control-group">
                        @Html.LabelFor(m => m.Teams)
                        @for (int i = 0; i < Model.Teams.Length; i++)
                        {
                            @Html.ActionLink(@Model.Teams[i].DisplayName, "Detail", "Team", new { id = @Model.Teams[i].Id }, null)
                            if (i + 1 != Model.Teams.Length)
                            {
                                <text>, </text>
                            }
                        }
                    </div>
                <div class="pure-controls">
                <a class="pure-button" href="@Url.Action("Index")"><i class="fa fa-long-arrow-left"></i> @Resources.Repository_Detail_Back</a>
                @if (Model.IsCurrentUserAdministrator)
                {
                    <a class="pure-button" href="@Url.Action("Edit", new { id = Model.Id })"><i class="fa fa-pencil-square-o"></i> @Resources.Repository_Detail_Edit</a>
                    <a class="pure-button" href="@Url.Action("Delete", new { id = Model.Id })"><i class="fa fa-trash-o"></i> @Resources.Repository_Detail_Delete</a>
                }
                </div>
</fieldset>
    </div>
}

@section scripts
{
    <script>new Clipboard('.copy-to-clip-button');</script>
}
